package com.ljyhhh.SmartCity.base.user

import android.content.Context
import okhttp3.*

class UserLogin{
    fun login(username: String, password: String, context: Context): Call {
//        Thread{
        val requestBody = FormBody.Builder()
            .add("studentNumber", username)
            .add("password", password)
            .build()
        val requests = Request.Builder()
            .url("http://8.137.8.86/api/student/login")
            .post(requestBody)
            .build()
        return OkHttpClient().newCall(requests)
//            val res=response.body?.string()
//            val root= JSONObject.parseObject(res)
//            val code=root.getBooleanValue("success")
//                .enqueue(object : Callback {
//                    override fun onFailure(call: Call, e: IOException) {
//                        Toast.makeText(context,"发生错误", Toast.LENGTH_SHORT).show()
//                    }
//
//                    override fun onResponse(call: Call, response: Response) {
//                        val res=response.body?.string()
//                        val root= JSONObject.parseObject(res)
//                        val code=root.getBooleanValue("success")
//                    }
//                })
//        }.start()
    }


}